#ifndef DECODER_FLAC_METADATA_TYPES_H_
#define DECODER_FLAC_METADATA_TYPES_H_

#include "cuesheet.h"
#include <string>

/* ======================= *
 * ::::: STREAMINFO :::::: *
 * ======================= */

enum FLACmetatype {
	FLAC_STREAMINFO,
	FLAC_PADDING,
	FLAC_APPLICATION,
	FLAC_SEEKTABLE,
	FLAC_VORBIS_COMMENT,
	FLAC_CUESHEET,
	FLAC_PICTURE,
	FLAC_ERROR
};

struct FLACstreaminfo
	{
	uint16_t minblocksize; /* in samples */
	uint16_t maxblocksize; /* in samples */
	uint32_t minframesize; /* in bytes */
	uint32_t maxframesize; /* in bytes */
	uint32_t samplerate;
	uint8_t  channels;
	uint8_t  bitspersample;
	uint32_t samples;
	uint8_t  md5[16];
};

/* ======================== *
* ::::: APPLICATION :::::: *
* ======================== */

struct FLACapplication
{
	uint32_t appid; // Registered application ID.
	void *data; // Application data
};	

/* ====================== *
* ::::: SEEKTABLE :::::: *
* ====================== */

struct FLACseekpoint
{
	uint64_t samplenumber; // Sample number of first sample in the target frame, or 0xFFFFFFFFFFFFFFFF for a placeholder point.
	uint64_t offset;       // Offset (in bytes) from the first byte of the first frame header to the first byte of the target frame's header.
	uint16_t samples;      // Number of samples in the target frame.

	/* Notes:
	* - For placeholder points, the second and third field values are undefined.
	* - Seek points within a table must be sorted in ascending order by sample number.
	* - Seek points within a table must be unique by sample number, with the exception of placeholder points.
	* - The previous two notes imply that there may be any number
		of placeholder points, but they must all occur at the end of the table. */
};
	// The number of seek points is implied by the metadata header 'length' field, i.e. equal to length / 18.

/* =================== *
* ::::: VORBIS ::::::: *
* ==================== */

struct FLAComment
{
	std::string name;
	std::string data;
};

struct FLACvorbis
{
	std::string vendorString;
	std::vector<FLAComment> comments;
};

/* ==================== *
* ::::: PICTURE :::::: *
* ==================== */

struct FLACpicture
{
	uint32_t type; // The picture type according to the ID3v2 APIC frame.
	uint32_t mimesize; // The length of the MIME type string in bytes.
	char *mimetype; /* The MIME type string, in printable ASCII characters 0x20-0x7e.
					 The MIME type may also be --> to signify that the data part
					 is a URL of the picture instead of the picture data itself. */
	uint32_t desclength; // The length of the description string in bytes.
	char *description; // The description of the picture, in UTF-8.
	uint32_t width; // The width of the picture in pixels.
	uint32_t height; // The height of the picture in pixels.
	uint32_t bps; // The color depth of the picture in bits-per-pixel.
	uint32_t colors; // For indexed-color pictures (e.g. GIF), the number of colors used, or 0 for non-indexed pictures.
	uint32_t datalength; // The length of the picture data in bytes.
	void *data; // The binary picture data.
};

#endif /* DECODER_FLAC_METADATA_TYPES_H_ */
